home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Development Tools & Languages / • Other Platforms / PCCTS 1.31 / dlg / dlg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-10  |  6.4 KB  |  180 lines  |  [TEXT/MPS ]

  1. /* dlg header file
  2.  *
  3.  * SOFTWARE RIGHTS
  4.  *
  5.  * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
  6.  * Set (PCCTS) -- PCCTS is in the public domain.  An individual or
  7.  * company may do whatever they wish with source code distributed with
  8.  * PCCTS or the code generated by PCCTS, including the incorporation of
  9.  * PCCTS, or its output, into commerical software.
  10.  * 
  11.  * We encourage users to develop software with PCCTS.  However, we do ask
  12.  * that credit is given to us for developing PCCTS.  By "credit",
  13.  * we mean that if you incorporate our source code into one of your
  14.  * programs (commercial product, research project, or otherwise) that you
  15.  * acknowledge this fact somewhere in the documentation, research report,
  16.  * etc...  If you like PCCTS and have developed a nice tool with the
  17.  * output, please mention that you developed it using PCCTS.  In
  18.  * addition, we ask that this header remain intact in our source code.
  19.  * As long as these guidelines are kept, we expect to continue enhancing
  20.  * this system and expect to make other tools available as they are
  21.  * completed.
  22.  *
  23.  * DLG 1.31
  24.  * Will Cohen
  25.  * With mods by Terence Parr; AHPCRC, University of Minnesota
  26.  * 1989-1995
  27.  */
  28. #include "set.h"
  29.  
  30. #define TRUE    1
  31. #define FALSE    0
  32.  
  33. /***** output related stuff *******************/
  34. #define IN    input_stream
  35. #define OUT    output_stream
  36.  
  37. #define MAX_MODES    50    /* number of %%names allowed */
  38. #define MAX_ON_LINE    10
  39.  
  40. #define NFA_MIN        64    /* minimum nfa_array size */
  41. #define DFA_MIN        64    /* minimum dfa_array size */
  42.  
  43. #define DEFAULT_CLASSNAME "DLGLexer"
  44.  
  45. /* these macros allow the size of the character set to be easily changed */
  46. /* NOTE: do NOT change MIN_CHAR since EOF is the lowest char, -1 */
  47. #define MIN_CHAR (-1)    /* lowest possible character possible on input */
  48. #define MAX_CHAR 255    /* highest possible character possible on input */
  49. #define CHAR_RANGE (1+(MAX_CHAR) - (MIN_CHAR))
  50.  
  51. /* indicates that the not an "array" reference */
  52. #define NIL_INDEX 0
  53.  
  54. /* size of hash table used to find dfa_states quickly */
  55. #define HASH_SIZE 211
  56.  
  57. #define nfa_node struct _nfa_node
  58. nfa_node {
  59.     int        node_no;
  60.     int        nfa_set;
  61.     int        accept;    /* what case to use */
  62.     nfa_node    *trans[2];
  63.     set        label;    /* one arc always labelled with epsilon */
  64. };
  65.  
  66. #define dfa_node struct _dfa_node
  67. dfa_node {
  68.     int        node_no;
  69.     int        dfa_set;
  70.     int        alternatives;    /* used for interactive mode */
  71.                     /* are more characters needed */
  72.     int        done;
  73.     set        nfa_states;
  74.     int        trans[1];/* size of transition table depends on
  75.                   * number of classes required for automata.
  76.                   */
  77.  
  78.  
  79. };
  80.  
  81. /******** macros for accessing the NFA and DFA nodes ****/
  82. #define NFA(x)    (nfa_array[x])
  83. #define DFA(x)    (dfa_array[x])
  84. #define DFA_NO(x) ( (x) ? (x)->node_no : NIL_INDEX)
  85. #define NFA_NO(x) ( (x) ? (x)->node_no : NIL_INDEX)
  86.  
  87. /******** wrapper for memory checking ***/
  88. /*#define malloc(x)    dlg_malloc((x),__FILE__,__LINE__)*/
  89.  
  90. /*#define calloc(x,y)    dlg_calloc((x),(y),__FILE__,__LINE__)*/
  91.  
  92. /******** antlr attributes *************/
  93. typedef struct {
  94.     unsigned char letter;
  95.     nfa_node *l,*r;
  96.     set label;
  97.     } Attrib;
  98.  
  99. #define zzcr_attr(attr, token, text) {                    \
  100.     (attr)->letter = text[0]; (attr)->l = NULL;            \
  101.     (attr)->r = NULL; (attr)->label = empty;            \
  102. }
  103. #define zzd_attr(a)    set_free((a)->label);
  104.  
  105. /******************** Variable ******************************/
  106. extern char    program[];    /* tells what program this is */
  107. extern char    version[];    /* tells what version this is */
  108. extern char    *file_str[];    /* file names being used */
  109. extern int    err_found;    /* flag to indicate error occured */
  110. extern int    action_no;    /* last action function printed */
  111. extern int    func_action;    /* should actions be turned into functions?*/
  112. extern set    used_chars;    /* used to label trans. arcs */
  113. extern set    used_classes;    /* classes or chars used to label trans. arcs */
  114. extern int    class_no;    /* number of classes used */
  115. extern set    class_sets[];    /* shows char. in each class */
  116. extern set    normal_chars;    /* mask off unused portion of set */
  117. extern int    comp_level;    /* what compression level to use */
  118. extern int    interactive;    /* interactive scanner (avoid lookahead)*/
  119. extern int    mode_counter;    /* keeps track of the number of %%name */
  120. extern int    dfa_basep[];    /* start of each group of dfa */
  121. extern int    dfa_class_nop[];/* number of transistion arcs in */
  122.                 /* each dfa in each mode */
  123. extern int    nfa_allocated;
  124. extern int    dfa_allocated;
  125. extern nfa_node    **nfa_array;    /* start of nfa "array" */
  126. extern dfa_node    **dfa_array;    /* start of dfa "array" */
  127. extern int    operation_no;    /* unique number for each operation */
  128. extern FILE    *input_stream;    /* where description read from */
  129. extern FILE    *output_stream; /* where to put the output */
  130. extern FILE    *mode_stream;    /* where to put the mode output */
  131. extern FILE    *class_stream;
  132. extern char    *mode_file;    /* name of file for mode output */
  133. extern int    gen_ansi;    /* produce ansi compatible code */
  134. extern int    case_insensitive;/* ignore case of input spec. */
  135. extern int    warn_ambig;    /* show if regular expressions ambiguous */
  136. extern int    gen_cpp;
  137. extern char *cl_file_str;
  138. extern char *outdir;
  139.  
  140. /******************** Functions ******************************/
  141. #ifdef __STDC__
  142. extern char     *dlg_malloc(int, char *, int); /* wrapper malloc */
  143. extern char     *dlg_calloc(int, int, char *, int); /* wrapper calloc */
  144. extern int    reach(unsigned *, register int, unsigned *);
  145. extern set    closure(set *, unsigned *);
  146. extern dfa_node *new_dfa_node(set);
  147. extern nfa_node *new_nfa_node(void);
  148. extern dfa_node *dfastate(set);
  149. extern dfa_node **nfa_to_dfa(nfa_node *);
  150. extern        internal_error(char *, char *, int);
  151. extern FILE    *read_stream(char *);    /* opens file for reading */
  152. extern FILE    *write_stream(char *);    /* opens file for writing */
  153. extern void    make_nfa_model_node(void);
  154. extern void    make_dfa_model_node(int);
  155. extern char *ClassName(char *);
  156. extern char *OutMetaName(char *);
  157. extern void error(char*, int);
  158. extern void warning(char*, int);
  159. #else
  160. extern char *dlg_malloc();    /* wrapper malloc */
  161. extern char *dlg_calloc();    /* wrapper calloc */
  162. extern int    reach();
  163. extern set    closure();
  164. extern dfa_node *new_dfa_node();
  165. extern nfa_node *new_nfa_node();
  166. extern dfa_node *dfastate();
  167. extern dfa_node **nfa_to_dfa();
  168. extern        internal_error();
  169. extern FILE    *read_stream();        /* opens file for reading */
  170. extern FILE    *write_stream();    /* opens file for writing */
  171. extern void    make_nfa_model_node();
  172. extern void    make_dfa_model_node();
  173. extern char *ClassName();
  174. extern char *OutMetaName();
  175. extern void error();
  176. extern void warning();
  177. #endif
  178.  
  179. #include "config.h"
  180.